﻿#include <iostream>
#include<vector>
using namespace std;

//搜索插入位置
class Solution1_2 {
public:
  int searchInsert(std::vector<int>& nums, int target) {
    int numsLen = nums.size();
    int res = -1, i;
    for (i = 0; i < numsLen; ++i) {
      if (target <= nums[i] && res == -1) {
        res = i;
      }
      if (target == nums[i]) {
        res = i;
        break;
      }
    }
    if (res == -1) {
      return i;
    }
    return res;
  }
};
